package java_test.collection;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class ArrayToCollection {
    public static void main(String[] args) throws IOException {
        int n = 5;
        String[] name = new String[n];
        for (int i = 0; i < n; i++) {
            name[i] = String.valueOf(i);
        }
        System.out.println(name);

        List<String> list = Arrays.asList(name);
        System.out.println();
        for (String item : list)
            System.out.println(item);

        List<String> listed = new ArrayList<String>();
        listed.add("菜");
        listed.add("鸟");
        listed.add("教");
        listed.add("程");
        listed.add("www.runoob.com");
        String[] s1 = listed.toArray(new String[0]);
        for (int i = 0; i < s1.length; ++i) {
            String contents = s1[i];
            System.out.print(contents);
        }
        // 该方法是将数组转化成List集合的方法
        List list3 = Arrays.asList("one Two three Four five six one three Four".split(" "));
        System.out.println(list);
        System.out.println("最大值: " + Collections.max(list3));
        System.out.println("最小值: " + Collections.min(list3));
    }
}
